#ifndef STATS_H
#define STATS_H
#include "../core/actor.h"

class stats:public node{
protected:
    actor* parent_;
    float hp,max_hp,mana,max_mana,damage,mana_regen;
    float invincible_time_ = 2.0f;      // 受伤后，无敌时间有多长
    float invincible_timer_ = 0.0f;     // 无敌计时器
    bool is_alive_ = true;
    bool is_invincible_ = false;
public:
    stats():hp(0.0f),max_hp(0.0f),mana(0.0f),max_mana(0.0f),
    damage(0.0f), mana_regen(0.0f){};
    static stats* createStats(actor* parent,const char* name,float max_hp = 100.0f,
        float max_mana = 100.0f,float damage = 10.0f,float mana_regen = 5.0f);
    virtual void update(float dt) override;
    bool isAlive(){return is_alive_; };
    void setAlive(bool is_alive){is_alive_ = is_alive;};
    bool isCanUseMana(float cost){return mana >= cost;};
    void useMana(float cost);
    void regenMana(float dt);
    void takeDamage(float damage);

    float getHp(){return hp;};
    void setHp(float hp_){this->hp = hp_;};
    float getMaxHp(){return max_hp;};
    void setMaxHp(float max_hp_){this->max_hp = max_hp_;};
    float getMana(){return mana;};
    void setMana(float mana_){this->mana = mana_;};
    float getMaxMana(){return max_mana;};
    void setMaxMana(float max_mana_){this->max_mana = max_mana_;};
    float getdamage(){return damage;};
    void setdamage(float damage_){this->damage = damage_;};
    float getManaRegen(){return mana_regen;};
    void setManaRegen(float mana_regen_){this->mana_regen = mana_regen_;};
    bool isInvincible(){return is_invincible_;};
    float getInvincibleTime(){return invincible_time_;};
    
};
#endif // STATS_H